<?php

class DefaultAction extends Action
{
    public function _initialize()
    {
        if (!session('identity')) {
            $this->show("<script>top.window.alert('请登录系统！'); top.location.href ='" . U("Home/index") . "'</script>");
            return;
        }
        $yhxx = new YHXX();
        if ($yhxx->fetch(session('identity'))) { //session非法
            session('identity', null);
            session('yhxx', null);
            $this->show("<script>top.window.alert('用户状态异常，请重新登录系统！'); top.location.href ='" . U("Home/index") . "'</script>");
            return;
        }
        $yhzmklist = YHZMK::query(array('YHZXX_BH' => $yhxx->YHZXX_BH))['DataList']; //无访问权限
        foreach ($yhzmklist as $item) {
            if (strcmp($this->getActionName(), $item->getMKXX()->MKXX_KZQ) == 0) {
                return;
            }
        }
        $this->show("<script>top.window.alert('您无权访问该功能--" . $this->getActionName() . "，如系正常访问，请与管理员联系解决！'); top.location.href ='" . U("Home/index") . "'</script>");
    }
}